{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\pe52\Dropbox\Research\ECM\EquationBalanceNote\PSRM_Replication\EnnsWlezien_TableA2.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res} 3 Feb 2018, 13:44:38

{com}. do "C:\Users\pe52\Dropbox\Research\ECM\EquationBalanceNote\PSRM_Replication\EnnsWlezien_Appendix_CombinedTS_q_Table_A2.do"
{txt}
{com}. **********************************************************************************************88
. **********************************************************************************************88
. **********************************************************************************************88
. *Combined Time Series, True Relationship
. **********************************************************************************************88
. **********************************************************************************************88
. **********************************************************************************************88
. 
. *Show current version
. version
{txt}version 14.2

{com}. *Set to Stata version 13.1
. version 13.1
{txt}
{com}. *************************
. **T=50; x1, rho=.2, .5, .8
. *************************
. set seed 4545
{txt}
{com}. 
. ******
. *rho=.2
. *****
. *program drop combined
. program define combined
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 50
{txt}  3{com}. gen t = _n
{txt}  4{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  5{com}. gen x1=e1 if t==1
{txt}  6{com}. replace x1=.2*x1[_n-1] + e1 if t>1
{txt}  7{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  8{com}. gen x2=u if t==1
{txt}  9{com}. replace x2=x2[_n-1] + u if t>1
{txt} 10{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 11{com}. gen z = .5*x1 + .5*x2 + q
{txt} 12{com}. tsset t
{txt} 13{com}. reg z l.z x1 l.x1 
{txt} 14{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, stationary x1, integrated x2)
. *can correctly identify TRUE relationships
. simulate _b _se, reps(1000) nodots: combined
{p2colset 7 17 21 2}{...}

{txt}{p2col :command:}combined{p_end}


{com}. 
. sum

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .5270724    .2215203  -.2453131   .9676885
{txt}{space 7}_b_x1 {c |}{res}      1,000    .5105899    .2008674  -.1669656   1.237617
{txt}{space 6}_sim_3 {c |}{res}      1,000   -.2726632    .2271245  -.9375757    .455673
{txt}{space 5}_b_cons {c |}{res}      1,000   -.0375908    .9047984  -3.811275     3.5789
{txt}{space 6}_sim_5 {c |}{res}      1,000    .1205448    .0218462   .0484259   .1752438
{txt}{hline 13}{c +}{hline 57}
{space 6}_se_x1 {c |}{res}      1,000    .1994868    .0342082   .1186877   .3272656
{txt}{space 6}_sim_7 {c |}{res}      1,000    .2090547    .0333801   .1277229   .3523298
{txt}{space 4}_se_cons {c |}{res}      1,000    .2867092    .0914524   .1409708   .6390104
{txt}
{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many regressions we gen tstat_x1 = abs(_b_x1/_se_x1)
. gen tstat_ly = abs(_sim_1/_sim_5)
{txt}
{com}. sum tstat_ly if tstat_ly>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_ly {c |}{res}        854    5.570724    2.770584   1.974681   19.34278
{txt}
{com}. 
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}        733    3.104728    .8410487   1.964563   6.863287
{txt}
{com}. *
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}        287     2.64449    .5825831   1.964164   5.059593
{txt}
{com}. 
.  
. ******
. *rho=.5
. *****
. program drop combined
{txt}
{com}. program define combined
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 50
{txt}  3{com}. gen t = _n
{txt}  4{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  5{com}. gen x1=e1 if t==1
{txt}  6{com}. replace x1=.5*x1[_n-1] + e1 if t>1
{txt}  7{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  8{com}. gen x2=u if t==1
{txt}  9{com}. replace x2=x2[_n-1] + u if t>1
{txt} 10{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 11{com}. gen z = .5*x1 + .5*x2 + q
{txt} 12{com}. tsset t
{txt} 13{com}. reg z l.z x1 l.x1 
{txt} 14{com}. end
{txt}
{com}. 
. simulate _b _se, reps(1000) nodots: combined
{p2colset 7 17 21 2}{...}

{txt}{p2col :command:}combined{p_end}


{com}. 
. sum

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .5160043    .2196165  -.1783758   .9627261
{txt}{space 7}_b_x1 {c |}{res}      1,000    .5062579     .197134  -.1434817   1.067177
{txt}{space 6}_sim_3 {c |}{res}      1,000   -.2601083    .2344992  -1.117029   .5968553
{txt}{space 5}_b_cons {c |}{res}      1,000   -.0145409    .9213603  -3.425852   3.131966
{txt}{space 6}_sim_5 {c |}{res}      1,000    .1214156    .0211572   .0517523   .1702821
{txt}{hline 13}{c +}{hline 57}
{space 6}_se_x1 {c |}{res}      1,000    .1982532    .0313432   .1194922   .3356293
{txt}{space 6}_sim_7 {c |}{res}      1,000    .2082135    .0307501   .1253042   .3309708
{txt}{space 4}_se_cons {c |}{res}      1,000     .289966    .0948149   .1427566   .6744074
{txt}
{com}. 
. gen tstat_ly = abs(_sim_1/_sim_5)
{txt}
{com}. sum tstat_ly if tstat_ly>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_ly {c |}{res}        844    5.424697    2.673205   1.966101   18.60257
{txt}
{com}. 
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}        725     3.11958    .7706889   1.981587   6.836909
{txt}
{com}. *
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}        274     2.67206    .6188652   1.961145   4.882092
{txt}
{com}. 
.  
. ******
. *rho=.8
. *****
. program drop combined
{txt}
{com}. program define combined
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 50
{txt}  3{com}. gen t = _n
{txt}  4{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  5{com}. gen x1=e1 if t==1
{txt}  6{com}. replace x1=.8*x1[_n-1] + e1 if t>1
{txt}  7{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  8{com}. gen x2=u if t==1
{txt}  9{com}. replace x2=x2[_n-1] + u if t>1
{txt} 10{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 11{com}. gen z = .5*x1 + .5*x2 + q
{txt} 12{com}. tsset t
{txt} 13{com}. reg z l.z x1 l.x1 
{txt} 14{com}. end
{txt}
{com}. 
. simulate _b _se, reps(1000) nodots: combined
{p2colset 7 17 21 2}{...}

{txt}{p2col :command:}combined{p_end}


{com}. 
. sum

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .4963764    .2222892  -.1261104   .9272442
{txt}{space 7}_b_x1 {c |}{res}      1,000    .4997845    .2137798  -.1702476   1.382443
{txt}{space 6}_sim_3 {c |}{res}      1,000   -.2574693    .2384709  -1.135275   .5535895
{txt}{space 5}_b_cons {c |}{res}      1,000    .0284291    .9345658  -3.029302   2.954133
{txt}{space 6}_sim_5 {c |}{res}      1,000    .1236503    .0207463     .05389   .1723414
{txt}{hline 13}{c +}{hline 57}
{space 6}_se_x1 {c |}{res}      1,000     .197231     .033594    .118816   .3374902
{txt}{space 6}_sim_7 {c |}{res}      1,000    .2080727    .0326975   .1225163   .3468495
{txt}{space 4}_se_cons {c |}{res}      1,000    .2976474    .0956312   .1386537   .6520124
{txt}
{com}. 
. gen tstat_ly = abs(_sim_1/_sim_5)
{txt}
{com}. sum tstat_ly if tstat_ly>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_ly {c |}{res}        829    5.176638    2.537154   1.969685   16.44412
{txt}
{com}. 
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}        710    3.173936    .8564285    1.96076   6.920125
{txt}
{com}. *
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}        279    2.688907    .6280217   1.961653   5.428679
{txt}
{com}. 
. 
.  
. *************************
. **T=100; x1, rho=.2, .5, .8
. *************************
. 
. ******
. *rho=.2
. *****
. program drop combined
{txt}
{com}. program define combined
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 100
{txt}  3{com}. gen t = _n
{txt}  4{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  5{com}. gen x1=e1 if t==1
{txt}  6{com}. replace x1=.2*x1[_n-1] + e1 if t>1
{txt}  7{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  8{com}. gen x2=u if t==1
{txt}  9{com}. replace x2=x2[_n-1] + u if t>1
{txt} 10{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 11{com}. gen z = .5*x1 + .5*x2 + q
{txt} 12{com}. tsset t
{txt} 13{com}. reg z l.z x1 l.x1 
{txt} 14{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, stationary x1, integrated x2)
. *can correctly identify TRUE relationships
. simulate _b _se, reps(1000) nodots: combined
{p2colset 7 17 21 2}{...}

{txt}{p2col :command:}combined{p_end}


{com}. 
. sum

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .6898874     .161659   .1127532   .9594744
{txt}{space 7}_b_x1 {c |}{res}      1,000    .4980432    .1386781   .0201026    .952593
{txt}{space 6}_sim_3 {c |}{res}      1,000   -.3419982    .1572377  -.8164515   .3445366
{txt}{space 5}_b_cons {c |}{res}      1,000    .0169512    .7398297  -2.161291   2.537839
{txt}{space 6}_sim_5 {c |}{res}      1,000    .0707261    .0158526   .0320321   .1033942
{txt}{hline 13}{c +}{hline 57}
{space 6}_se_x1 {c |}{res}      1,000    .1439132    .0167801     .10039    .205815
{txt}{space 6}_sim_7 {c |}{res}      1,000    .1483285    .0165003   .1070853   .2081861
{txt}{space 4}_se_cons {c |}{res}      1,000    .2134224    .0680375   .1124543   .4682759
{txt}
{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many regressions we gen tstat_x1 = abs(_b_x1/_se_x1)
. gen tstat_ly = abs(_sim_1/_sim_5)
{txt}
{com}. sum tstat_ly if tstat_ly>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_ly {c |}{res}        997    10.91521    5.141375   1.969342    29.8472
{txt}
{com}. 
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}        933    3.649318    .9155736   1.975317   7.286213
{txt}
{com}. *
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}        644    2.951767    .7189643   1.960319   5.642876
{txt}
{com}. 
.  
. ******
. *rho=.5
. *****
. program drop combined
{txt}
{com}. program define combined
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 100
{txt}  3{com}. gen t = _n
{txt}  4{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  5{com}. gen x1=e1 if t==1
{txt}  6{com}. replace x1=.5*x1[_n-1] + e1 if t>1
{txt}  7{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  8{com}. gen x2=u if t==1
{txt}  9{com}. replace x2=x2[_n-1] + u if t>1
{txt} 10{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 11{com}. gen z = .5*x1 + .5*x2 + q
{txt} 12{com}. tsset t
{txt} 13{com}. reg z l.z x1 l.x1 
{txt} 14{com}. end
{txt}
{com}. 
. simulate _b _se, reps(1000) nodots: combined
{p2colset 7 17 21 2}{...}

{txt}{p2col :command:}combined{p_end}


{com}. 
. sum

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .6924955    .1638949   .0777036    .967079
{txt}{space 7}_b_x1 {c |}{res}      1,000    .5003325    .1474121   .0051042   .9778415
{txt}{space 6}_sim_3 {c |}{res}      1,000   -.3467238    .1640507  -.8116443   .1080973
{txt}{space 5}_b_cons {c |}{res}      1,000   -.0111078    .7549906  -2.670009     2.1885
{txt}{space 6}_sim_5 {c |}{res}      1,000    .0702958    .0163564   .0232595   .1042984
{txt}{hline 13}{c +}{hline 57}
{space 6}_se_x1 {c |}{res}      1,000    .1426127    .0164058   .0922053   .2009521
{txt}{space 6}_sim_7 {c |}{res}      1,000    .1473532    .0159021   .0948946   .2013231
{txt}{space 4}_se_cons {c |}{res}      1,000    .2140999     .068136   .0954333   .5400943
{txt}
{com}. 
. gen tstat_ly = abs(_sim_1/_sim_5)
{txt}
{com}. sum tstat_ly if tstat_ly>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_ly {c |}{res}        994    11.17815    5.557615   2.002096   41.57775
{txt}
{com}. 
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}        924    3.736427     .983262   1.962746    7.13416
{txt}
{com}. *
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}        633    3.072751    .7630856   1.969167   6.144748
{txt}
{com}. 
.  
. ******
. *rho=.8
. *****
. program drop combined
{txt}
{com}. program define combined
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 100
{txt}  3{com}. gen t = _n
{txt}  4{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  5{com}. gen x1=e1 if t==1
{txt}  6{com}. replace x1=.8*x1[_n-1] + e1 if t>1
{txt}  7{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  8{com}. gen x2=u if t==1
{txt}  9{com}. replace x2=x2[_n-1] + u if t>1
{txt} 10{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 11{com}. gen z = .5*x1 + .5*x2 + q
{txt} 12{com}. tsset t
{txt} 13{com}. reg z l.z x1 l.x1 
{txt} 14{com}. end
{txt}
{com}. 
. simulate _b _se, reps(1000) nodots: combined
{p2colset 7 17 21 2}{...}

{txt}{p2col :command:}combined{p_end}


{com}. 
. sum

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .6767334     .166421   .0930865   .9829441
{txt}{space 7}_b_x1 {c |}{res}      1,000    .4990055    .1437402   .0230062   1.033488
{txt}{space 6}_sim_3 {c |}{res}      1,000   -.3362725    .1679155  -.8779722   .1353566
{txt}{space 5}_b_cons {c |}{res}      1,000    .0107884    .7970003  -2.523738   2.243693
{txt}{space 6}_sim_5 {c |}{res}      1,000    .0716515    .0162447    .026973   .1027382
{txt}{hline 13}{c +}{hline 57}
{space 6}_se_x1 {c |}{res}      1,000    .1424467    .0161549    .096037   .1921155
{txt}{space 6}_sim_7 {c |}{res}      1,000     .147519    .0156433   .0958299   .1975656
{txt}{space 4}_se_cons {c |}{res}      1,000    .2220162     .071479   .1131454   .4970713
{txt}
{com}. 
. gen tstat_ly = abs(_sim_1/_sim_5)
{txt}
{com}. sum tstat_ly if tstat_ly>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_ly {c |}{res}        998     10.6677    5.433885   2.224535   35.63672
{txt}
{com}. 
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}        937    3.687471    .9871264   1.961192   7.544222
{txt}
{com}. *
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}        608    3.023868    .8181194   1.964314   6.377828
{txt}
{com}. 
.  
. *************************
. **T=5,000; x1, rho=.2, .5, .8
. *************************
. 
. ******
. *rho=.2
. *****
. program drop combined
{txt}
{com}. program define combined
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  5{com}. gen x1=e1 if t==1
{txt}  6{com}. replace x1=.2*x1[_n-1] + e1 if t>1
{txt}  7{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  8{com}. gen x2=u if t==1
{txt}  9{com}. replace x2=x2[_n-1] + u if t>1
{txt} 10{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 11{com}. gen z = .5*x1 + .5*x2 + q
{txt} 12{com}. tsset t
{txt} 13{com}. reg z l.z x1 l.x1 
{txt} 14{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, stationary x1, integrated x2)
. *can correctly identify TRUE relationships
. simulate _b _se, reps(1000) nodots: combined
{p2colset 7 17 21 2}{...}

{txt}{p2col :command:}combined{p_end}


{com}. 
. sum

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .9901771    .0075103   .9414053   .9993898
{txt}{space 7}_b_x1 {c |}{res}      1,000     .500407    .0209505   .4338395   .5694295
{txt}{space 6}_sim_3 {c |}{res}      1,000   -.4955319    .0209983  -.5594464  -.4298264
{txt}{space 5}_b_cons {c |}{res}      1,000    .0057574     .155035  -.6423457   .5542758
{txt}{space 6}_sim_5 {c |}{res}      1,000    .0018483    .0006976   .0005049   .0047742
{txt}{hline 13}{c +}{hline 57}
{space 6}_se_x1 {c |}{res}      1,000    .0211695    .0003219   .0200294   .0221946
{txt}{space 6}_sim_7 {c |}{res}      1,000    .0211921    .0003194   .0200671   .0221931
{txt}{space 4}_se_cons {c |}{res}      1,000    .0347184    .0114157   .0207368   .0838024
{txt}
{com}. 
. *Generate t-statistic for each simulated regression and evaluate how many regressions we gen tstat_x1 = abs(_b_x1/_se_x1)
. gen tstat_ly = abs(_sim_1/_sim_5)
{txt}
{com}. sum tstat_ly if tstat_ly>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_ly {c |}{res}      1,000     623.822    261.5919   197.1864   1979.366
{txt}
{com}. 
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}      1,000    23.64471    1.080097   20.47665   27.08939
{txt}
{com}. *
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}      1,000     23.3886    1.061034   20.57502   26.93873
{txt}
{com}. 
.  
. ******
. *rho=.5
. *****
. program drop combined
{txt}
{com}. program define combined
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  5{com}. gen x1=e1 if t==1
{txt}  6{com}. replace x1=.5*x1[_n-1] + e1 if t>1
{txt}  7{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  8{com}. gen x2=u if t==1
{txt}  9{com}. replace x2=x2[_n-1] + u if t>1
{txt} 10{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 11{com}. gen z = .5*x1 + .5*x2 + q
{txt} 12{com}. tsset t
{txt} 13{com}. reg z l.z x1 l.x1 
{txt} 14{com}. end
{txt}
{com}. 
. simulate _b _se, reps(1000) nodots: combined
{p2colset 7 17 21 2}{...}

{txt}{p2col :command:}combined{p_end}


{com}. 
. sum

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .9901945    .0074135   .9513509   .9993742
{txt}{space 7}_b_x1 {c |}{res}      1,000    .5002667    .0205839   .4374317   .5665919
{txt}{space 6}_sim_3 {c |}{res}      1,000   -.4953692    .0211909  -.5573632  -.4311921
{txt}{space 5}_b_cons {c |}{res}      1,000   -.0031879    .1514795  -.6081118    .684093
{txt}{space 6}_sim_5 {c |}{res}      1,000    .0018495    .0006934   .0004869   .0043325
{txt}{hline 13}{c +}{hline 57}
{space 6}_se_x1 {c |}{res}      1,000    .0211784    .0003316   .0201101   .0222248
{txt}{space 6}_sim_7 {c |}{res}      1,000    .0212027     .000331     .02016   .0222741
{txt}{space 4}_se_cons {c |}{res}      1,000    .0346287    .0114743   .0206773   .0840537
{txt}
{com}. 
. gen tstat_ly = abs(_sim_1/_sim_5)
{txt}
{com}. sum tstat_ly if tstat_ly>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_ly {c |}{res}      1,000    623.5726    263.4764   219.5859   2052.341
{txt}
{com}. 
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}      1,000    23.62607    1.009979   20.75502   27.04249
{txt}
{com}. *
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}      1,000    23.36801    1.039287   20.40709   26.28706
{txt}
{com}. 
.  
. ******
. *rho=.8
. *****
. program drop combined
{txt}
{com}. program define combined
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  5{com}. gen x1=e1 if t==1
{txt}  6{com}. replace x1=.8*x1[_n-1] + e1 if t>1
{txt}  7{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  8{com}. gen x2=u if t==1
{txt}  9{com}. replace x2=x2[_n-1] + u if t>1
{txt} 10{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 11{com}. gen z = .5*x1 + .5*x2 + q
{txt} 12{com}. tsset t
{txt} 13{com}. reg z l.z x1 l.x1 
{txt} 14{com}. end
{txt}
{com}. 
. simulate _b _se, reps(1000) nodots: combined
{p2colset 7 17 21 2}{...}

{txt}{p2col :command:}combined{p_end}


{com}. 
. sum

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      1,000    .9902411    .0075643   .9517154   .9994353
{txt}{space 7}_b_x1 {c |}{res}      1,000    .4996448     .020924   .4305542   .5709723
{txt}{space 6}_sim_3 {c |}{res}      1,000   -.4944802     .021566  -.5646287  -.4176571
{txt}{space 5}_b_cons {c |}{res}      1,000   -.0009019    .1556199  -.5891448   .5609072
{txt}{space 6}_sim_5 {c |}{res}      1,000    .0018387    .0007055   .0004978   .0043416
{txt}{hline 13}{c +}{hline 57}
{space 6}_se_x1 {c |}{res}      1,000     .021168    .0003322   .0201044    .022429
{txt}{space 6}_sim_7 {c |}{res}      1,000    .0211922    .0003303   .0201119   .0224554
{txt}{space 4}_se_cons {c |}{res}      1,000     .035039    .0117912   .0206458   .0781736
{txt}
{com}. 
. gen tstat_ly = abs(_sim_1/_sim_5)
{txt}
{com}. sum tstat_ly if tstat_ly>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_ly {c |}{res}      1,000    630.2764    270.3631   219.2077   2007.541
{txt}
{com}. 
. gen tstat_x1 = abs(_b_x1/_se_x1)
{txt}
{com}. sum tstat_x1 if tstat_x1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 4}tstat_x1 {c |}{res}      1,000    23.61013    1.067337   20.00797   26.85289
{txt}
{com}. *
. gen tstat_lx1 = abs(_sim_3/_sim_7)
{txt}
{com}. sum tstat_lx1 if tstat_lx1>=1.96

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 3}tstat_lx1 {c |}{res}      1,000    23.33899    1.085345   19.38941   26.59443
{txt}
{com}. 
. 
{txt}end of do-file

{com}. 